package com.alstudio.utils.mission.parser;

import com.alstudio.utils.mission.ALMissionHttpManager.MissionInfoCallback;
import com.alstudio.utils.mission.parser.base.BaseMissionXmlParser;
import com.alstudio.utils.xml.BaseXmlParser.XmlParseCallback;

public class XmlNameSpaceParser extends BaseMissionXmlParser implements
		XmlParseCallback {

	private final String QUERY_TAG = "query";
	private String ns;
	private CheckNameSpaceCallback callback;

	public interface CheckNameSpaceCallback {
		public void onGetNameSpace(String ns);
	}

	public XmlNameSpaceParser(CheckNameSpaceCallback callback) {
		// TODO Auto-generated constructor stub
		this.callback = callback;
	}

	/* (non-Javadoc)
	 * @see com.alstudio.utils.mission.parser.base.BaseMissionXmlParser#parseXmlPackage(java.lang.String, com.alstudio.utils.mission.ALMissionHttpManager.MissionInfoCallback)
	 */
	@Override
	public void parseXmlPackage(String stream, MissionInfoCallback listener)
			throws Exception {
		// TODO Auto-generated method stub
		super.parseXmlPackage(stream, listener);
		startParse(stream, this);
	}
	
	@Override
	public void onTagStart(String tag) {
		// TODO Auto-generated method stub
		if (QUERY_TAG.equals(tag)) {
			ns = getAttValue("xmlns");
			this.callback.onGetNameSpace(ns);
		}
	}

	@Override
	public void onTagEnd(String tag) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onDocumentStart() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onDocumentEnd() {
		// TODO Auto-generated method stub

	}

}
